Skip to content

feat: add lapack/base/dlarf#12331

Open
iampratik13 wants to merge 7 commits into
stdlib-js:developfrom
iampratik13:lapack/dlarf
Open

feat: add lapack/base/dlarf#12331
iampratik13 wants to merge 7 commits into
stdlib-js:developfrom
iampratik13:lapack/dlarf

Conversation

@iampratik13
Copy link
Copy Markdown
Member


type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes. report:

  • task: lint_filenames status: passed
  • task: lint_editorconfig status: passed
  • task: lint_markdown_pkg_readmes status: passed
  • task: lint_markdown_docs status: na
  • task: lint_markdown status: na
  • task: lint_package_json status: passed
  • task: lint_repl_help status: passed
  • task: lint_javascript_src status: passed
  • task: lint_javascript_cli status: na
  • task: lint_javascript_examples status: passed
  • task: lint_javascript_tests status: passed
  • task: lint_javascript_benchmarks status: passed
  • task: lint_python status: na
  • task: lint_r status: na
  • task: lint_c_src status: na
  • task: lint_c_examples status: na
  • task: lint_c_benchmarks status: na
  • task: lint_c_tests_fixtures status: na
  • task: lint_shell status: na
  • task: lint_typescript_declarations status: passed
  • task: lint_typescript_tests status: passed
  • task: lint_license_headers status: passed ---

Resolves none.

Description

What is the purpose of this pull request?

This pull request:

  • feat: add lapack/base/dlarf

Related Issues

Does this pull request have any related issues?

This pull request has the following related issues:

  • none.

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

No.

Checklist

Please ensure the following tasks are completed before submitting this pull request.

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of AI assistance?

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Disclosure

If you answered "yes" to using AI assistance, please provide a short disclosure indicating how you used AI assistance. This helps reviewers determine how much scrutiny to apply when reviewing your contribution. Example disclosures: "This PR was written primarily by Claude Code." or "I consulted ChatGPT to understand the codebase, but the proposed changes were fully authored manually by myself.".

{{TODO: add disclosure if applicable}}


@stdlib-js/reviewers

---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: passed
  - task: lint_markdown_pkg_readmes
    status: passed
  - task: lint_markdown_docs
    status: na
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: passed
  - task: lint_repl_help
    status: passed
  - task: lint_javascript_src
    status: passed
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: passed
  - task: lint_javascript_tests
    status: passed
  - task: lint_javascript_benchmarks
    status: passed
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: passed
  - task: lint_typescript_tests
    status: passed
  - task: lint_license_headers
    status: passed
---
@iampratik13 iampratik13 requested a review from a team May 28, 2026 11:39
@stdlib-bot stdlib-bot added LAPACK Issue or pull request related to the Linear Algebra Package (LAPACK). Needs Review A pull request which needs code review. labels May 28, 2026
@stdlib-bot
Copy link
Copy Markdown
Contributor

stdlib-bot commented May 28, 2026

Coverage Report

Package Statements Branches Functions Lines
lapack/base/dlarf $\color{green}459/459$
$\color{green}+0.00\%$
$\color{green}44/44$
$\color{green}+0.00\%$
$\color{green}4/4$
$\color{green}+0.00\%$
$\color{green}459/459$
$\color{green}+0.00\%$

The above coverage report was generated for the changes in this PR.

@iampratik13 iampratik13 added Feature Issue or pull request for adding a new feature. JavaScript Issue involves or relates to JavaScript. GSoC Google Summer of Code. gsoc: 2026 Google Summer of Code (2026). labels May 28, 2026
@iampratik13 iampratik13 requested a review from anandkaranubc May 28, 2026 11:48
@anandkaranubc
Copy link
Copy Markdown
Contributor

anandkaranubc and others added 3 commits May 31, 2026 15:59
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: passed
  - task: lint_markdown_pkg_readmes
    status: passed
  - task: lint_markdown_docs
    status: na
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: na
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: na
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: passed
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: passed
  - task: lint_markdown_pkg_readmes
    status: passed
  - task: lint_markdown_docs
    status: na
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: na
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: na
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: passed
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
* @param {Float64Array} work - workspace array
* @throws {TypeError} first argument must be a valid order
* @throws {TypeError} second argument must be a valid side
* @throws {RangeError} ninth argument must be greater than or equal to max(1,N)
Copy link
Copy Markdown
Contributor

@anandkaranubc anandkaranubc May 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* @throws {RangeError} ninth argument must be greater than or equal to max(1,N)

That only applies to row-major. Column-major has no LDC check in code, and LAPACK expects LDC >= max(1, M) for column-major.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iampratik13 Mind verifying this commit if this looks good? Thanks!

---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: passed
  - task: lint_markdown_pkg_readmes
    status: passed
  - task: lint_markdown_docs
    status: na
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: passed
  - task: lint_javascript_src
    status: passed
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: passed
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: passed
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
```

The function has the following additional parameters:
The function has the following parameters:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are not "additional"

// Scan for the last non-zero row in C(:,0:lastv-1):
lastc = iladlr( M, lastv, C, strideC1, strideC2, offsetC ) + 1; // adjust by +1 to account for the difference between zero-based and one-based indexing
}
// Note that lastc === 0 renders the BLAS operations null; no special case is needed at this level...
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Note that lastc === 0 renders the BLAS operations null; no special case is needed at this level...
// Return `C` unchanged if all elements in `C` are zero...
if ( lastc === 0 ) {
return C;
}

I think it's better to have an early return instead.

---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: passed
  - task: lint_markdown_pkg_readmes
    status: na
  - task: lint_markdown_docs
    status: na
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: passed
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: na
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: passed
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
Comment on lines +66 to +67
* @throws {RangeError} if `order` is `'row-major'`, ninth argument must be greater than or equal to max(1,N)
* @throws {RangeError} if `order` is `'column-major'`, ninth argument must be greater than or equal to max(1,M)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @throws {RangeError} if `order` is `'row-major'`, ninth argument must be greater than or equal to max(1,N)
* @throws {RangeError} if `order` is `'column-major'`, ninth argument must be greater than or equal to max(1,M)
* @throws {RangeError} ninth argument must be a valid stride

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is okay to be a bit more general in throws descriptions.

Comment on lines +95 to +107
if ( isRowMajor( order ) && LDC < max( 1, N ) ) {
throw new RangeError( format( 'invalid argument. Ninth argument must be greater than or equal to max(1,%d). Value: `%d`.', N, LDC ) );
}
if ( isColumnMajor( order ) && LDC < max( 1, M ) ) {
throw new RangeError( format( 'invalid argument. Ninth argument must be greater than or equal to max(1,%d). Value: `%d`.', M, LDC ) );
}
if ( isColumnMajor( order ) ) {
sc1 = 1;
sc2 = LDC;
} else { // order === 'row-major'
sc1 = LDC;
sc2 = 1;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be consolidated. Avoid unnecessary and duplicate branching.

Suggested change
if ( isRowMajor( order ) && LDC < max( 1, N ) ) {
throw new RangeError( format( 'invalid argument. Ninth argument must be greater than or equal to max(1,%d). Value: `%d`.', N, LDC ) );
}
if ( isColumnMajor( order ) && LDC < max( 1, M ) ) {
throw new RangeError( format( 'invalid argument. Ninth argument must be greater than or equal to max(1,%d). Value: `%d`.', M, LDC ) );
}
if ( isColumnMajor( order ) ) {
sc1 = 1;
sc2 = LDC;
} else { // order === 'row-major'
sc1 = LDC;
sc2 = 1;
}
if ( isColumnMajor( order ) ) {
if ( LDC < max( 1, M ) ) {
throw new RangeError( format( 'invalid argument. Ninth argument must be greater than or equal to max(1,%d). Value: `%d`.', M, LDC ) );
}
sc1 = 1;
sc2 = LDC;
} else { // order === 'row-major'
if ( LDC < max( 1, N ) ) {
throw new RangeError( format( 'invalid argument. Ninth argument must be greater than or equal to max(1,%d). Value: `%d`.', N, LDC ) );
}
sc1 = LDC;
sc2 = 1;
}

It is likely we need to touch up some other packages to reduce branching and duplicate calls. Feel free to open a PR fixing this.

@kgryte kgryte added Needs Changes Pull request which needs changes before being merged. and removed Needs Review A pull request which needs code review. labels Jun 1, 2026
Comment on lines +126 to +130
// w(0:lastc-1) := C(0:lastv-1, 0:lastc-1)^T * v(0:lastv-1)
dgemv( 'transpose', lastv, lastc, 1.0, C, strideC1, strideC2, offsetC, V, strideV, offsetV, 0.0, work, strideWork, offsetWork );

// C(0:lastv-1, 0:lastc-1) := C(...) - tau * v(0:lastv-1) * w(0:lastc-1)^T
dger( lastv, lastc, -tau, V, strideV, offsetV, work, strideWork, offsetWork, C, strideC1, strideC2, offsetC );
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// w(0:lastc-1) := C(0:lastv-1, 0:lastc-1)^T * v(0:lastv-1)
dgemv( 'transpose', lastv, lastc, 1.0, C, strideC1, strideC2, offsetC, V, strideV, offsetV, 0.0, work, strideWork, offsetWork );
// C(0:lastv-1, 0:lastc-1) := C(...) - tau * v(0:lastv-1) * w(0:lastc-1)^T
dger( lastv, lastc, -tau, V, strideV, offsetV, work, strideWork, offsetWork, C, strideC1, strideC2, offsetC );
// work[0:lastc-1] := C[0:lastv-1, 0:lastc-1]^T * V[0:lastv-1]
dgemv( 'transpose', lastv, lastc, 1.0, C, strideC1, strideC2, offsetC, V, strideV, offsetV, 0.0, work, strideWork, offsetWork );
// C[0:lastv-1, 0:lastc-1] := C[...] - tau * V[0:lastv-1] * work[0:lastc-1]^T
dger( lastv, lastc, -tau, V, strideV, offsetV, work, strideWork, offsetWork, C, strideC1, strideC2, offsetC );

Keeping them consistent with our variable names, and how we write similar comments in other reference implementations.

Comment on lines +137 to +141
// w(0:lastc-1) := C(0:lastc-1, 0:lastv-1) * v(0:lastv-1)
dgemv( 'no-transpose', lastc, lastv, 1.0, C, strideC1, strideC2, offsetC, V, strideV, offsetV, 0.0, work, strideWork, offsetWork );

// C(0:lastc-1, 0:lastv-1) := C(...) - tau * w(0:lastc-1) * v(0:lastv-1)^T
dger( lastc, lastv, -tau, work, strideWork, offsetWork, V, strideV, offsetV, C, strideC1, strideC2, offsetC );
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// w(0:lastc-1) := C(0:lastc-1, 0:lastv-1) * v(0:lastv-1)
dgemv( 'no-transpose', lastc, lastv, 1.0, C, strideC1, strideC2, offsetC, V, strideV, offsetV, 0.0, work, strideWork, offsetWork );
// C(0:lastc-1, 0:lastv-1) := C(...) - tau * w(0:lastc-1) * v(0:lastv-1)^T
dger( lastc, lastv, -tau, work, strideWork, offsetWork, V, strideV, offsetV, C, strideC1, strideC2, offsetC );
// work[0:lastc-1] := C[0:lastc-1, 0:lastv-1] * V[0:lastv-1]
dgemv( 'no-transpose', lastc, lastv, 1.0, C, strideC1, strideC2, offsetC, V, strideV, offsetV, 0.0, work, strideWork, offsetWork );
// C[0:lastc-1, 0:lastv-1] := C[...] - tau * work[0:lastc-1] * V[0:lastv-1]^T
dger( lastc, lastv, -tau, work, strideWork, offsetWork, V, strideV, offsetV, C, strideC1, strideC2, offsetC );

---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: passed
  - task: lint_markdown_pkg_readmes
    status: na
  - task: lint_markdown_docs
    status: na
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: passed
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: na
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: passed
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature Issue or pull request for adding a new feature. GSoC Google Summer of Code. gsoc: 2026 Google Summer of Code (2026). JavaScript Issue involves or relates to JavaScript. LAPACK Issue or pull request related to the Linear Algebra Package (LAPACK). Needs Changes Pull request which needs changes before being merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants